<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:96:"D:\PHPStudy\PHPTutorial\WWW\HM\pdingzone\public/../application/core\view\site\module\detail.html";i:1544678555;s:84:"D:\PHPStudy\PHPTutorial\WWW\HM\pdingzone\application\core\view\common\pc\header.html";i:1544678555;s:84:"D:\PHPStudy\PHPTutorial\WWW\HM\pdingzone\application\core\view\common\pc\footer.html";i:1544678555;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>模块详情 - <?php echo $siteConfig['siteName']; ?></title>
    <meta name="keywords" content="<?php echo $siteConfig['siteKeyword']; ?>"/>
    <meta name="description" content="<?php echo $siteConfig['siteDesc']; ?>"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="<?php echo $siteConfig['favicon']; ?>" type="image/x-icon" rel="shortcut icon"/>
    <link rel="stylesheet" href="/static/layui/2.4.3/src/css/layui.css?v=20181010_1" media="all">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_731151_u29ky3lpahq.css?v=20181010_1" media="all">
    <link rel="stylesheet" href="/static/css/pc.css?v=20181010_1" media="all">
    <script src="/static/js/jquery.min.js?v=20181010_1" charset="utf-8"></script>
    <script src="/static/layui/2.4.3/src/layui.js?v=20181010_1" charset="utf-8"></script>
    <script src="/static/js/common.js?v=20181010_1" charset="utf-8"></script>
    <script src="/static/js/pc.js?v=20181010_1" charset="utf-8"></script>

    <?php if($siteConfig['theme']): ?>
    <link rel="stylesheet" href="/static/css/theme/<?php echo $siteConfig['theme']; ?>/pc.css?v=20181010_1" media="all">
    <?php endif;  if(\think\App::$debug){  ?>
    <!-- 调试窗口 -->
    <script src="/static/js/vconsole/vconsole.min.js?v=20181010_1" charset="utf-8"></script>
    <script>
        // 调试窗口初始化
        new VConsole();
    </script>
    <?php  }  ?>
</head>

<body class="layui-layout-body pc-body">


<style>
    #modules-detail img {
        width: 100px;
        height: 100px;
    }

    #enterprises img {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        cursor: pointer;
    }

    #enterprises li {
        float: left;
    }
</style>

<div id="modules-detail">
    <table class="layui-table">
        <tr>
            <td rowspan="2" width="100">
                <img src="/<?php echo $module['name']; ?>/logo.png" onerror="this.src='/static/images/module.png';"/>
            </td>
            <td>模块ID:
                <?php if(isset($module['id'])): ?>
                <?php echo $module['id']; endif; ?>
            </td>
            <td>模块标识: <?php echo $module['name']; ?></td>
            <td>模块名称: <?php echo $module['title']; ?></td>
        </tr>
        <tr>
            <td>模块版本：<?php echo $module['version']; ?></td>
            <td>
                模块作者: <?php echo $module['author']; ?><br/>
                <a href="<?php echo $module['url']; ?>" target="_blank"><?php echo $module['url']; ?></a>
            </td>
            <td colspan="2">
                模块描述: <?php echo $module['description']; ?>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                模块状态：
                <?php if($module['status'] == 'inactive'): ?>
                <span class="layui-badge layui-bg-orange">未启用</span>
                <?php elseif($module['status'] == 'active'): ?>
                <span class="layui-badge layui-bg-green">已启用</span>
                <?php elseif($module['status'] == 'uninstall' || $module['status'] == 'undownload'): ?>
                <span class="layui-badge layui-bg-red">未安装</span>
                <?php endif; if($module['status'] == 'active'): ?>
                共有&nbsp;<span class="layui-badge layui-bg-blue"><?php  echo count($enterprises)  ?></span>&nbsp;家企业正在使用本模块
                <br/>
                <ul id="enterprises">
                    <?php if(is_array($enterprises) || $enterprises instanceof \think\Collection || $enterprises instanceof \think\Paginator): if( count($enterprises)==0 ) : echo "" ;else: foreach($enterprises as $key=>$enterprise): ?>
                    <li data-enterprise='<?php echo json_encode($enterprise); ?>'>
                        <img src="<?php echo $enterprise['logo']; ?>" onerror="this.src='/static/images/enterprise.png'"
                             alt="<?php echo $enterprise['title']; ?>"/>
                    </li>
                    <?php endforeach; endif; else: echo "" ;endif; ?>
                </ul>
                <?php endif; ?>
            </td>
            <td>
                <?php if($module['status'] == 'inactive'): ?>
                <a class="layui-btn layui-btn-sm layui-btn-success" href="javascript:;" id="active">启用模块</a>
                <a class="layui-btn layui-btn-sm layui-btn-danger" href="javascript:;" id="uninstall">卸载模块</a>
                <?php elseif($module['status'] == 'active'): ?>
                <a class="layui-btn layui-btn-sm layui-btn-warm" href="javascript:;" id="inactive">停用模块</a>
                <?php elseif($module['status'] == 'undownload' || $module['status'] == 'uninstall'): ?>
                <a class="layui-btn layui-btn-sm" href="javascript:;" id="install">安装模块</a>
                <?php endif; ?>
            </td>
        </tr>
    </table>
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title">
            <li class="layui-this">API列表</li>
            <li>后台菜单</li>
            <li>前台入口</li>
            <li>配置项</li>
            <li>功能权限</li>
            <li>微应用</li>
            <li>挂件</li>
            <li>定时任务</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col width="150">
                        <col>
                        <col width="150">
                        <col width="250">
                    </colgroup>
                    <thead>
                    <tr>
                        <td>API名称</td>
                        <td>API标题</td>
                        <td>API介绍</td>
                        <td>API分组</td>
                        <td title="本模块需要授权访问的字段信息">
                            授权字段
                        </td>
                    </tr>
                    </thead>
                    <tbody>
                    <?php if(is_array($apiInfos) || $apiInfos instanceof \think\Collection || $apiInfos instanceof \think\Paginator): if( count($apiInfos)==0 ) : echo "" ;else: foreach($apiInfos as $apiName=>$apiInfo): ?>
                    <tr>
                        <td><?php echo $apiName; ?></td>
                        <td><?php echo $apiInfo['title']; ?></td>
                        <td><?php echo $apiInfo['desc']; ?></td>
                        <td><?php echo $apiInfo['group']; ?></td>
                        <td>
                            <?php if(isset($apiInfo['fieldInfos']) && is_array($apiInfo['fieldInfos'])): ?>
                            <ul>
                                <?php if(is_array($apiInfo['fieldInfos']) || $apiInfo['fieldInfos'] instanceof \think\Collection || $apiInfo['fieldInfos'] instanceof \think\Paginator): if( count($apiInfo['fieldInfos'])==0 ) : echo "" ;else: foreach($apiInfo['fieldInfos'] as $fieldName=>$fieldTitle): ?>
                                <li><?php echo $fieldName; ?>（<?php echo $fieldTitle; ?>）</li>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </ul>
                            <?php endif; ?>
                        </td>
                    </tr>
                    <?php endforeach; endif; else: echo "" ;endif; ?>
                    </tbody>
                </table>
            </div>
            <div class="layui-tab-item"></div>
            <div class="layui-tab-item"></div>
            <div class="layui-tab-item"></div>
            <div class="layui-tab-item"></div>
            <div class="layui-tab-item"></div>
            <div class="layui-tab-item"></div>
            <div class="layui-tab-item"></div>
        </div>
    </div>
</div>

<script id="enterpriseInfo" type="text/html">
    <ul class="enterpriseInfoList">
        <li>企业名称：{{ d.title || '' }}</li>
        <li>联系人：{{ d.contacter || '' }}</li>
        <li>联系电话：{{ d.phone || '' }}</li>
        <li>企业备注：{{ d.description || '' }}</li>
    </ul>
</script>

<script>
    layui.use(['laytpl', 'element'], function () {
        window.laytpl = layui.laytpl;
    });

    // 企业列表鼠标悬浮显示企业信息
    $("#enterprises li").mouseover(function () {
        var that = this;
        var enterprise = eval("(" + $(this).attr("data-enterprise") + ")");
        laytpl($("#enterpriseInfo").html()).render(enterprise, function (html) {
            var idx = layer.tips(html, that, {time: 0});
            $(that).data("layer_tips_idx", idx);
        });
    });
    $("#enterprises li").mouseout(function () {
        layer.close($(this).data("layer_tips_idx"));
    });

    // 企业列表点击显示企业信息
    $("#enterprises li").click(function () {
        var enterprise = eval("(" + $(this).attr("data-enterprise") + ")");
        console.dir(enterprise);
        var link = "/core/site.enterprise/detail?eid=" + enterprise.id;
        if (window.parent && window.parent.openTab) {
            window.parent.openTab(false, link, "site_enterprise_" + enterprise.id);
        } else {
            window.location.href = link;
        }
    });

    // 启用模块
    $("#active").click(function () {
        var confirmContent = '您确定要<span class="layui-badge layui-bg-green">启用</span>模块【<?php echo $module['title']; ?>】?';
        layer.confirm(confirmContent, {title: '询问'}, function (index) {
            g.loading();
            $.post("/core/site.module/active/" + encodeURIComponent('<?php echo $module['name']; ?>'), {_: new Date().getTime()}, function (ret) {
                layer.close(index);
                g.loading(false);
                if (ret.code == 0) {
                    layer.alert(ret.msg);
                } else {
                    layer.msg("操作成功，页面刷新中...")
                    document.location.href = "/core/site.module/detail/<?php echo $module['name']; ?>";
                }
            }, "json");
        });
    });

    // 停用模块
    $("#inactive").click(function () {
        var html = "";
        var enterprisesCount = $("#enterprises li").length;
        if (enterprisesCount > 0) {
            html += "<span style='color:red;'>停用应用将会导致<span class='layui-badge layui-bg-red'>" + enterprisesCount + "</span>家企业的应用无法使用！</span><br/>";
        }
        html += '您确定要继续<span class="layui-badge layui-bg-orange">停用</span>模块【<?php echo $module['title']; ?>】吗?';
        layer.confirm(html, {title: '询问'}, function (index) {
            g.loading();
            $.post("/core/site.module/inactive/" + encodeURIComponent('<?php echo $module['name']; ?>'), {_: new Date().getTime()}, function (ret) {
                layer.close(index);
                g.loading(false);
                if (ret.code == 0) {
                    layer.alert(ret.msg);
                } else {
                    layer.msg("操作成功，页面刷新中...")
                    document.location.href = "/core/site.module/detail/<?php echo $module['name']; ?>";
                }
            }, "json");
        });
    });

    // 安装模块
    $("#install").click(function () {
        var confirmContent = '您确定要<span class="layui-badge layui-bg-green">安装</span>模块【<?php echo $module['title']; ?>】吗?';
        layer.confirm(confirmContent, {title: '询问'}, function (index) {
            g.loading();
            $.post("/core/site.module/install/" + encodeURIComponent('<?php echo $module['name']; ?>'), {_: new Date().getTime()}, function (ret) {
                layer.close(index);
                g.loading(false);
                if (ret.code == 0) {
                    layer.alert(ret.msg);
                } else {
                    layer.msg("操作成功，页面刷新中...")
                    document.location.href = "/core/site.module/detail/<?php echo $module['name']; ?>";
                }
            }, "json");
        });
    });

    // 卸载模块
    $("#uninstall").click(function () {
        var confirmContent = '<span style="color: red;">卸载模块将会删除模块相关的所有业务数据</span>，' +
            '您确定要继续<span class="layui-badge layui-bg-danger">卸载</span>模块【<?php echo $module['title']; ?>】吗?';
        var confirmEditContent = '<span style="color: red;">卸载模块将会删除模块相关的所有业务数据</span><br/>' +
            '如果要继续删除，请输入当前模块标识：' +
            '<input class="layui-input" type="input" placeholder="请输入当前要删除的模块标识"/>';
        layer.confirm(confirmContent, {title: '询问'}, function (confirmIndex) {
            layer.alert(confirmEditContent, {title: '危险操作再次确认'}, function (confirmEditIndex, layero) {
                if (layero.find("input").val() != '<?php echo $module['name']; ?>') {
                    layer.alert("模块标识输入错误，无法卸载模块", {zIndex: 99999999});
                    return;
                }
                layer.close(confirmEditIndex);
                g.loading();
                $.post("/core/site.module/uninstall/" + encodeURIComponent('<?php echo $module['name']; ?>'), {_: new Date().getTime()}, function (ret) {
                    layer.close(confirmIndex);
                    g.loading(false);
                    if (ret.code == 0) {
                        layer.alert(ret.msg);
                    } else {
                        layer.msg("操作成功，页面刷新中...")
                        document.location.href = "/core/site.module/detail/<?php echo $module['name']; ?>";
                    }
                }, "json");
            });
        });
    });
</script>

<!-- 初始化操作 -->
<?php if(isset($initAction) && $initAction): ?>
<script>
    $(document).ready(function () {
        layui.use(['layer'], function () {
            setTimeout('$("#<?php echo $initAction; ?>").click()', 500);
        });
    });
</script>
<?php endif; 
if(isset($_enterprise_js_css_customize)) {
echo $_enterprise_js_css_customize;
}
 ?>
</body>
</html>